package com.eos.orm.mybatis.dao.impl;

import java.util.ArrayList;
import java.util.List;

import org.apache.ibatis.session.SqlSession;

import com.eos.orm.mybatis.dao.SalesModelMapper;
import com.eos.orm.mybatis.model.SalesModel;
import com.eos.orm.mybatis.model.SalesModelExample;

/**
 * sales_model销售方式表的CURD操作
 * 
 * @author sz
 * 
 */
public class SalesModelMapperImpl extends AbstractSqlSessionFactory implements
		SalesModelMapper {

	public int countByExample(SalesModelExample example) {
		return 0;
	}

	public int deleteByExample(SalesModelExample example) {
		return 0;
	}

	public int deleteByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			SalesModelMapper mapper = session.getMapper(SalesModelMapper.class);
			mapper.deleteByPrimaryKey(id);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.SalesModelMapperImpl.deleteByPrimaryKey throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

	public int insert(SalesModel record) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			SalesModelMapper mapper = session.getMapper(SalesModelMapper.class);
			mapper.insert(record);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.SalesModelMapperImpl.insert throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

	public int insertSelective(SalesModel record) {
		return 0;
	}

	public List<SalesModel> selectByExample(SalesModelExample example) {
		List<SalesModel> templist = new ArrayList<SalesModel>();
		SqlSession session = sqlSessionFactory.openSession();
		try {
			SalesModelMapper mapper = session.getMapper(SalesModelMapper.class);
			templist = mapper.selectByExample(example);
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.SalesModelMapperImpl.selectByExample throws exception:"
							+ e.getMessage());
		} finally {
			session.close();
		}
		return templist;
	}

	public SalesModel selectByPrimaryKey(Integer id) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			SalesModelMapper mapper = session.getMapper(SalesModelMapper.class);
			return mapper.selectByPrimaryKey(id);
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.SalesModelMapperImpl.selectByPrimaryKey throws exception:"
							+ e.getMessage());
		} finally {
			session.close();
		}
		return null;
	}

	public int updateByExample(SalesModel record, SalesModelExample example) {
		return 0;
	}

	public int updateByExampleSelective(SalesModel record,
			SalesModelExample example) {
		return 0;
	}

	public int updateByPrimaryKey(SalesModel record) {
		return 0;
	}

	public int updateByPrimaryKeySelective(SalesModel record) {
		SqlSession session = sqlSessionFactory.openSession();
		try {
			SalesModelMapper mapper = session.getMapper(SalesModelMapper.class);
			mapper.updateByPrimaryKeySelective(record);
			session.commit();
			mapper = null;
		} catch (Exception e) {
			System.out
					.println("com.eos.orm.mybatis.dao.impl.SalesModelMapperImpl.updateByPrimaryKeySelective throws exception:"
							+ e.getMessage());
			return -1;
		} finally {
			session.close();
		}
		return 0;
	}

}
